package com.cleaningcloud.cld.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldJobCategory;
import com.cleaningcloud.cld.service.ICldJobCategoryService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 职别基数Controller
 * 
 * @author cleaningcloud
 * @date 2024-10-23
 */
@RestController
@RequestMapping("/category")
public class CldJobCategoryController extends BaseController
{
    @Autowired
    private ICldJobCategoryService cldJobCategoryService;

    /**
     * 查询职别基数列表
     */
    @RequiresPermissions("cld:category:list")
    @GetMapping("/list")
    public TableDataInfo list(CldJobCategory cldJobCategory)
    {
        startPage();
        List<CldJobCategory> list = cldJobCategoryService.selectCldJobCategoryList(cldJobCategory);
        return getDataTable(list);
    }


    /**
     * 查询职别基数列表
     */
    @GetMapping("/getList")
    public AjaxResult getList(CldJobCategory cldJobCategory)
    {
        List<CldJobCategory> list = cldJobCategoryService.selectCldJobCategoryList(cldJobCategory);
        return success(list);
    }


    /**
     * 导出职别基数列表
     */
    @RequiresPermissions("cld:category:export")
    @Log(title = "职别基数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CldJobCategory cldJobCategory)
    {
        List<CldJobCategory> list = cldJobCategoryService.selectCldJobCategoryList(cldJobCategory);
        ExcelUtil<CldJobCategory> util = new ExcelUtil<CldJobCategory>(CldJobCategory.class);
        util.exportExcel(response, list, "职别基数数据");
    }

    /**
     * 获取职别基数详细信息
     */
    @RequiresPermissions("cld:category:query")
    @GetMapping(value = "/{jobCategoryId}")
    public AjaxResult getInfo(@PathVariable("jobCategoryId") Long jobCategoryId)
    {
        return success(cldJobCategoryService.selectCldJobCategoryByJobCategoryId(jobCategoryId));
    }

    /**
     * 新增职别基数
     */
    @RequiresPermissions("cld:category:add")
    @Log(title = "职别基数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldJobCategory cldJobCategory)
    {
        return toAjax(cldJobCategoryService.insertCldJobCategory(cldJobCategory));
    }

    /**
     * 修改职别基数
     */
    @RequiresPermissions("cld:category:edit")
    @Log(title = "职别基数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldJobCategory cldJobCategory)
    {
        return toAjax(cldJobCategoryService.updateCldJobCategory(cldJobCategory));
    }

    /**
     * 删除职别基数
     */
    @RequiresPermissions("cld:category:remove")
    @Log(title = "职别基数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{jobCategoryIds}")
    public AjaxResult remove(@PathVariable Long[] jobCategoryIds)
    {
        return toAjax(cldJobCategoryService.deleteCldJobCategoryByJobCategoryIds(jobCategoryIds));
    }
}
